package com.jiadakeji.ppm.api.v1;

import com.jiadakeji.ppm.api.common.JsonResult;
import com.jiadakeji.ppm.common.utils.StringUtils;
import com.jiadakeji.ppm.common.web.BaseController;
import com.jiadakeji.ppm.modules.business.entity.Advise;
import com.jiadakeji.ppm.modules.business.service.AdviseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController("v1_adviseController")
@RequestMapping(value = "${apiPath}/v1/advise")
public class AdviseController extends BaseController {
    @Autowired
    private AdviseService adviseService;

    @RequestMapping(value = "/putAdvise")
    @ApiOperation(value = "插入建议",httpMethod = "POST",consumes="application/json",notes="根据id")
    public JsonResult<String> putRepair(@RequestBody Advise advise, HttpServletRequest request, HttpServletResponse response){
        JsonResult<String> result = new JsonResult<>();

        if(StringUtils.isBlank(advise.getCustomerId())){
            return result.setCodeAndMessage(-1,"customerId不能为空");
        }
        adviseService.save(advise);
        return result;
    }


}
